<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/common/header.jsp"%>
<html>
<body class="easyui-layout list_body">
	<form id="menuForm" name="menuForm">
		<div class="list_body_north" data-options="region:'north'" border="false">
			<!-- 查询表单 -->
			<div style="padding: 3px" class="easyui-panel datagrid-toolbar">
				<div>
					<span>清算开始日期:</span>
					<input type="text" id="stl_dt_start" value="${yestedayDate}" name="stl_dt_start" class="easyui-datebox" data-options="editable:false"/>
					<span>清算结束日期:</span>
					<input type="text" id="stl_dt_end" value="${yestedayDate}" name="stl_dt_end" class="easyui-datebox" data-options="editable:false"/>
					<span>会员编号:</span>
					<input type="text" id="custom_no" name="custom_no" class="easyui-textbox" /> 
					<span>会员名称:</span> 
					<input type="text" id="custom_name" name="custom_name" class="easyui-textbox" /> 
					<br/>
					<span>手机号:</span>
					<input type="text" id="login_id" name="login_id" class="easyui-textbox" /> 
					<span>机构号:</span>
					<input type="text" id="ins_cd" name="ins_cd" class="easyui-textbox" /> 
					<span>交易渠道:</span>
					<input class="easyui-combobox" id="channel_no" name="channel_no" type="text"
						data-options="url:'../logStlmChntSum/getAllChannel.do', method:'get', valueField:'CHANNEL_NO', textField:'CHN_NM',editable:false"/> 
					<a href="#" class="easyui-linkbutton btn" iconCls="icon-search" onclick="doSearch()">查询</a> 
					<a href="#" class="easyui-linkbutton btn" iconCls="icon-reload" onclick="resetForm()">重置</a>
				</div>
			</div>
			<!-- 维护汇总数据 -->
			<div style="padding: 3px" class="easyui-panel datagrid-toolbar">
				交易总金额：<span id="allAmt"></span> 会员手续费汇总：<span id="allMidFee"></span>
				会员结算手续费汇总：<span id="allCustomStlFee"></span>
				机构结算手续费汇总：<span id="allInsStlFee"></span> 交易分润毛利汇总：<span id="allTpm"></span>
			</div>
			<jiepos:buttonOperateTag menuCode="${menuCode }"></jiepos:buttonOperateTag>
		</div>
		<div data-options="region:'center'" border="false" class="list_body_center">
			<!-- 表格 -->
			<table id="menuTableId" fit="true"></table>
		</div>
	</form>
</body>
<script type="text/javascript">
	var grid;
	$(function() {
		//加载业务名称数据
		$('#channel_no').combobox({
	        url:"../logStlmChntSum/getAllChannel.do",
	        valueField:'CHANNEL_NO',
	        textField:'CHN_NM'
		});
		getTotalInfo();
		/*加载表格数据*/
		grid = $("#menuTableId").jpgrid({
			url : "getLogListJson.do",
			baseColumns: false,
			columns : [ {
				title : "清算日期",
				field : "STL_DT",
				align : 'center',
                width:100
			}, {
				title : "会员编号",
				field : "CUSTOM_NO",
				align : 'center'
			}, {
				title : "会员名称",
				field : "CUSTOM_NAME",
				align : 'center'
			}, {
				title : "所属机构",
				field : "INS",
				align : 'center',
				width : 200
			}, {
				title : "业务名称",
				field : "SERVICE_NAME",
				align : 'center'
			}, {
				title : "业务参数名称",
				field : "SERVICE_PARAM_NAME",
				align : 'center'
			}, {
				title : "交易金额",
				field : "AMT",
				align : 'center',
                width:100
			}, {
				title : "交易笔数",
				field : "CNT",
				align : 'center',
                width:100
			}, {
				title : "会员手续费",
				field : "MIDFEE",
				align : 'center',
                width:100
			}, {
				title : "会员结算手续费",
				field : "CUSTOM_STL_FEE",
				align : 'center',
                width:100
			}, {
				title : "机构结算手续费",
				field : "INS_STL_FEE",
				align : 'center',
                width:100
			}, {
				title : "交易分润毛利",
				field : "PROFIT_MONEY",
				align : 'center',
                width:100
			}, {
                title : "交易渠道",
                field : "CHANNEL_NO",
                align : 'center',
                width:200
            }]
		});
	});

	function doSearch() {
		grid.load({
			stl_dt_start : $('#stl_dt_start').val(),
			stl_dt_end : $('#stl_dt_end').val(),
			custom_no : $('#custom_no').val(),
			custom_name : $('#custom_name').val(),
			login_id : $('#login_id').val(),
			ins_cd : $('#ins_cd').val(),
			channel_no : $('#channel_no').val()
		});
		getTotalInfo();
	}
	
	function getTotalInfo(){
		var data = {
				stl_dt_start : $('#stl_dt_start').val(),
				stl_dt_end : $('#stl_dt_end').val(),
				custom_no : $('#custom_no').val(),
				custom_name : $('#custom_name').val(),
				custom_phone : $('#custom_phone').val(),
				ins_cd : $('#ins_cd').val(),
				channel_no : $('#channel_no').val()
		};
		$.ajax({
			url : '../logStlmChntSum/getLogStlMchntInfoTotal.do',
			data : data,
			success : function(result) {
				$("#allAmt").html(result.ALL_AMT);
				$("#allMidFee").html(result.ALL_MIDFEE);
				$("#allInsStlFee").html(result.ALL_INS_STL_FEE);
				$("#allTpm").html(result.ALL_TPM);
				$("#allCustomStlFee").html(result.ALL_CUSTOM_STL_FEE);
			}
		});
	}

	function exportFile(url){
		var checkedItems = $('#menuTableId').datagrid('getChecked');
		if(!checkedItems){
			return false;
		};
		var ids = "";
		for(var i = 0 ; i < checkedItems.length; i++){
			ids = ids + "," + ((checkedItems[i]).STL_DT1+"_"+(checkedItems[i]).SERVICE_PARAM_UUID+"_"+(checkedItems[i]).CUSTOM_UUID);
		}
		ids = replaceFirst(ids);
		commonFileDownload(url+ids, "menuForm");
	}
</script>
</html>
